package com.lyf.scm.plan.api.controller;

import com.lyf.scm.plan.api.dto.SalesPlanDirectlyDTO;
import com.lyf.scm.plan.domain.service.SalesPlanDirectlyService;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.util.controller.RomeController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

/**
 * description:
 * 直营预测计划
 *
 * @author: haodong
 * @data: 2020/8/3 10:23
 */
@Slf4j
@Api(tags = "直营预测计划")
@RequestMapping("/api/v1/salesPlanDirectly")
@RomeController
public class SalesPlanDirectlyController {

    @Resource
    private SalesPlanDirectlyService salesPlanDirectlyService;


    @PostMapping("/updateConfirm")
    @ApiOperation(value = "更新确认量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "unitType", value = "单位类型", required = true, paramType = "query", dataType = "long"),
            @ApiImplicitParam(name = "level", value = "权限等级", required = true, paramType = "query", dataType = "integer"),
    })
    public Response updateConfirm(@RequestBody List<SalesPlanDirectlyDTO> directlyList, @RequestParam("unitType") Long unitType, @RequestParam("level") Integer level) {
        return Response.builderSuccess(salesPlanDirectlyService.updateConfirm(directlyList, unitType, level));
    }

    @PostMapping("/updateConfirmType")
    @ApiOperation(value = "更新计划状态")
    public Response updateConfirmType(@RequestParam("level") Integer level, @RequestParam("specifiedDate") String specifiedDate) {
        return Response.builderSuccess(salesPlanDirectlyService.updateConfirmType(level, specifiedDate));
    }
}
